<?php
require_once("../../../config.inc.php");
require_once("../../../app/_inc/include.php");

$objUser = $_SESSION[USEROBJ];
$numElem = 0;
$errMsg = "";
//carico l'elenco degli attributi
if(isset($_REQUEST["pu"]) && $_REQUEST["pu"] != ""){
	$process_unit = $_REQUEST["pu"];
	if(isset($_REQUEST["alias"]) && $_REQUEST["alias"] != ""){
		$alias = $_REQUEST["alias"];
		
		$sSQL = "SELECT * FROM pu_attribute WHERE process_unit='$process_unit' AND alias='$alias' ORDER BY entity, attribute";
		$errMsg = "";
		if(!$query = $objSDAO->query($sSQL, "pu")){
			$errMsg = $objSDAO->error;
			$errCode = $objSDAO->errno;
		}
	}else{
		$errMsg = _t("L'alias non &egrave; definito");
	}
}else{
	$errMsg = _t("Il processo non &egrave; definito");
}
//output HTML
$aOpz = array("tit2"=>_t("Lista degli attributi"));
echo(headerHTML($aOpz));
echo(bodyHTML($aOpz));
//output comandi
$aCmd = array("ins"=>array("pag"=>"puAttrIns.php?pu=$process_unit&alias=$alias",
										"title"=>_t("Inserisce un nuovo attribute"),
										"text"=>_t("nuovo attribute"),
										"perm"=>"newmod"),
					"back"=>array("pag"=>$objUser->getHistory(-1,false),
										"title"=>$objUser->getHistoryText(-1),
										"text"=>$objUser->getHistoryText(-1),
										"perm"=>"")
					);
echo(commandsHTML($aCmd));	
//output dei dati
echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"titl01\"colspan=\"3\">"._t("Attributi del processo")." $process_unit</td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"tabh01\" width=\"10%\">"._t('Alias')."</td>" .
		"<td class=\"tabh01\" width=\"10%\">"._t('Attributo')."</td>" .
		"<td class=\"tabh01\" width=\"90%\">"._t('Entit&agrave;')."</td>" .
	"</tr>\n");	
if($errMsg == ""){
	while($row = $objSDAO->fetch("pu")){
			if($objSDAO->error == ""){
				$numElem ++;
				echo("<tr>" .
						"<td class=\"text01\" valign='top'><a class=\"text01\" ".
							goToPag("puAttrView.php?pu=".$row["process_unit"]."&alias=".$row["alias"]."&ent=".$row["entity"]."&attr=".$row["attribute"]."&xsn=".XSN).
							" title=\""._t("Visualizza attribute")."'".$row["description"]."'\">".
							$row["alias"]."</a></td>\n" .
						"<td class=\"text01\" valign='top'>".$row["attribute"]."</td>" .
						"<td class=\"text01\" valign='top'>".$row["entity"]."</td>" .
					"</tr>\n");
			}else{
				echo("<tr>" .
						"<td class=\"text01\" colspan=\"3\">".$objSDAO->error."</td>" .
					"</tr>\n");
			}
		}
	if($numElem == 0)
		echo("<tr>" .
				"<td class=\"text01\" colspan=\"3\">"._t("Non &egrave; presente alcun attribute.")."</td>".
			"</tr>\n");
}
echo("</table>\n");
echo("<div id=\"mess01\" class=\"mess01\">$errMsg</div>");
echo(commandsHTML($aCmd));
echo(footerHTML());
?>
		
?>
